<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>产生a-b之间n个随机数</title>
	<script>
	function randomNum(start,end,n){
		var i=0,res=[];
		while(i<n){
			res[i]=Math.round(Math.random()*(end-start)+start);
			flag=true;
			//检查新产生的随机数是否和已有的随机数重复
			for(var j=0;j<i;j++){
				if(res[j]==res[i]){
					i--;
				}
			}
			i++;
		}
		return res;
	}
	document.write(randomNum(4,47,40));
	// a=Math.round(6.1258855);b=Math.round(6.1);
	// if (a==b) {document.write(a+","+b)};
	</script>
</head>
<body>
	
</body>
</html>